package org.noote.spidy.monitor;

import org.noote.libs.robot.Robot_ServoMotor;
import org.noote.libs.robot.object3d.Robot_Bone3D;
import org.noote.libs.robot.object3d.Robot_Skeleton3D;
import org.noote.libs.robot.object3d.helper.Mesh_Servo;
import org.noote.libs.sogle.Mesh;
import org.noote.libs.sogle.Vector3D;
import org.noote.libs.spidy.anim.Spidy_BaseSkeleton;
import org.noote.libs.spidy.anim.Spidy_WildRobot;

import android.content.Context;

public class Spidy_Skeleton3D extends Robot_Skeleton3D {
	
	public Spidy_Skeleton3D(Spidy_WildRobot bot) {
		super(bot);
	}
	
	public boolean create(Context context)
	{
		Mesh_Servo mesh_servo;
		Robot_ServoMotor servo;
		@SuppressWarnings("unused")
		Mesh mesh;
		
		////////////////////////
		// assemble all parts
		
		// corps !
		Robot_Bone3D corps = newBone();
		corps.set(new Vector3D(0, 0, 0), 1.0f);
		corps.createBox(11.0f, 5.1f, 18.8f, new Vector3D(0.0f, 0.0f, 0.0f), 1, 1, 1);
		
		// coxa avant gauche
		Robot_Bone3D lf_coxa = newBone();
		lf_coxa.setParent(corps);
		lf_coxa.set(new Vector3D(4.3f, 0.0f, 8.2f), 1.0f);
		lf_coxa.createBox(5.4f, 5.4f, 5.8f, new Vector3D(-1.2f, 0.0f, 0.0f), 1, 0, 0);
		mesh_servo = new Mesh_Servo(); // LEFT_FRONT_COXA
		mesh_servo.setPosition(0f, 0f, 0.0f);
		mesh_servo.setEulerRotation(0, 180f, 0f);
		lf_coxa.addMesh(mesh_servo);
		mesh_servo = new Mesh_Servo(); // LEFT_FRONT_FEMUR
		mesh_servo.setPosition(-2.4f, 0.0f, 0.0f);
		mesh_servo.setEulerRotation(-90, 180f, 0f);
		lf_coxa.addMesh(mesh_servo);
		
		// femur avant gauche
		Robot_Bone3D lf_femur = newBone();
		lf_femur.setParent(lf_coxa);
		lf_femur.set(new Vector3D(-2.4f, 0.0f, -1.9f), 1.0f);
		lf_femur.createBox(10.0f, 2.4f, 0.2f, new Vector3D(-3.2f, 0f, -0.1f), 0, 1, 0);
		
		/*
		// tibia avant gauche
		Robot_Bone3D lf_tibia = newBone();
		lf_tibia.setParent(lf_femur);
		lf_tibia.set(new Vector3D(0.8f, 0.0f, -7.3f), 1.0f);
		lf_tibia.createBox(10.0f, 1.4f, 0.2f, new Vector3D(-6.8f, 0f, 0f), 0, 1, 0);
		mesh_servo = new Mesh_Servo(); // LEFT_FRONT_TIBIA
		mesh_servo.setPosition(0f, 0f, 0.0f);
		mesh_servo.setEulerRotation(0, 0f, 0f);
		lf_tibia.addMesh(mesh_servo);*/
	
		//////////////////////////////////////////
		// create servos and associate to bones
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_FRONT_COXA);
		servo.setBone(lf_coxa);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_FRONT_FEMUR);
		servo.setBone(lf_femur);

		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_FRONT_TIBIA);
		//servo.setBone(lf_tibia);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_FRONT_COXA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_FRONT_FEMUR);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_FRONT_TIBIA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_MIDDLE_COXA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_MIDDLE_FEMUR);

		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_MIDDLE_TIBIA);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_MIDDLE_COXA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_MIDDLE_FEMUR);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_MIDDLE_TIBIA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_BACK_COXA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_BACK_FEMUR);

		servo = _robot.getServo(Spidy_BaseSkeleton.LEFT_BACK_TIBIA);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_BACK_COXA);
		
		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_BACK_FEMUR);

		servo = _robot.getServo(Spidy_BaseSkeleton.RIGHT_BACK_TIBIA);
		
		return true;
	}
}
